package cn.hl.hm.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import cn.hl.hm.entity.Order;
import cn.hl.hm.entity.RewardRecord;
import cn.hl.hm.service.RewardRecordService;
import cn.hl.hm.util.AppPager;
import cn.hl.hm.util.InfoCode;
import cn.hl.hm.util.Result;

/**
 * 奖励业务处理
 * @author LBJ
 *
 */
@Controller
@RequestMapping("/rewardRecordController")
public class RewardRecordController {
	private static final Logger logger = LoggerFactory.getLogger(OrderController.class);

	@Autowired
	RewardRecordService rewardRecordService;
	
	
	
	
	/**
	 * 获取司机的奖励列表
	 * @param driverId
	 * @param pageId
	 * @param pageCount
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/selectRewardRecordList", method = RequestMethod.POST)
	public String selectRewardRecordList(@RequestParam Integer driverId, @RequestParam Integer pageId,
	        @RequestParam Integer pageCount,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		logger.info("订单业务/司机管理---奖励收入列表/奖励列表---rewardRecordController/selectRewardRecordList");
		request.setCharacterEncoding("UTF-8");
		try {
			AppPager handle = AppPager.handle(pageId, pageCount);
			RewardRecord param = new RewardRecord();
			param.setPageId(handle.getPageId());
			param.setDriverId(driverId);
			param.setPageCount(handle.getPageCount());
			List<RewardRecord> rewardRecordList = rewardRecordService.selectRewardRecord(param);
			Result.ok(rewardRecordList, InfoCode.SUCCESS, response);
		} catch (Exception e) {
			Result.ok(null, InfoCode.FAILURE, response);
		}
		return null;
	}
	

}
